Modifies the CachedFetcher to not keep pending exceptions #253
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Because of the way the
CachedFetcherworked, if an exception was raised on a cached method, it would eternally keep a copy of the exception, and then when the event loop closed, would spit out a traceback for a never-retrieved-exception, like so:Traceback
Future exception was never retrieved future: Traceback (most recent call last): File "/Users/benjaminhimes/Git/btcli/bittensor_cli/src/commands/proxy.py", line 625, in execute_announced runtime = await subtensor.substrate.init_runtime(block_id=created_block) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/async_substrate.py", line 1433, in init_runtime runtime_version = await self.get_block_runtime_version_for(block_hash) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/utils/cache.py", line 332, in __call__ result = await self._method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/async_substrate.py", line 2390, in get_block_runtime_version_for return await self._get_block_runtime_version_for(block_hash) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/async_substrate.py", line 2394, in _get_block_runtime_version_for runtime_info = await self.get_block_runtime_info(parent_block_hash) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/utils/cache.py", line 332, in __call__ result = await self._method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/async_substrate.py", line 2377, in get_block_runtime_info return await self._get_block_runtime_info(block_hash) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/async_substrate.py", line 2382, in _get_block_runtime_info response = await self.rpc_request("state_getRuntimeVersion", [block_hash]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/async_substrate.py", line 2728, in rpc_request raise StateDiscardedError(bh) async_substrate_interface.errors.StateDiscardedError: State discarded for 0x32cf28ae40a6f5f89fa224fdffd5454314105eef3c7cf234bd4ea3b3ab92dbf2. This indicates the block is too old, and you should instead make this request using an archive node.This fixes that issue by not caching the exceptions.